package com.mind.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;

import org.apache.log4j.Logger;

import com.mind.core.net.model.IConnector;
import com.mind.core.net.processor.MessageProcessorDispatcher;
import com.mind.core.net.websocket.client.WebSocketClientHandler;
import com.mind.core.server.GameServerRuntime;
import com.mind.login.model.Player;

public class GameIoHandler extends WebSocketClientHandler {
	public GameIoHandler(WebSocketClientHandshaker handshaker) {
		super(handshaker);
	}
	private static final Logger log =Logger.getLogger(GameIoHandler.class);
	@Override
	public IConnector createConnector() {
		return new Player();
	}
	@Override
	public void handlerMessage(ChannelHandlerContext ctx, Object msg)
			throws Exception {
		if (GameServerRuntime.isReadTrafficControl()) {			
			if (MessageProcessorDispatcher.getInstance().isFull()) {
				//队列已经满了,停止session的读取
				ctx.channel().config().setAutoRead(false);
				log.warn("队列已经满了,停止session的读取");
			}
		}
	}
}
